%% Editor.tex - Editor chapter
%% Created by Robert Heller on Sat Mar 14 21:56:50 1992
%%
%% ------------------------------------------------------------------
%% Home Libarian by Deepwoods Software
%% ------------------------------------------------------------------
%% Modification History:
%% ------------------------------------------------------------------
%% Contents:
%% ------------------------------------------------------------------
%% 
%% 
%% Copyright (c) 1991,1992 by Robert heller (D/B/A Deepwoods Software)
%%        All Rights Reserved
%% 
%%
\chapter{Editing a Librarian Data Base.}
\index{card catalog db@{\bf card catalog db}!editing}
\label{Editor}

\newcommand{\EditLibr}{{\tt EditLibr}}

A Card Catalog Data Base is created and edited with the \EditLibr\ 
program. This program uses a simple menu-driven, terminal-based
GUI\footnote{See section~\ref{sec:GUI} for GUI definations.}.  

\section{Invoking \EditLibr.}

\EditLibr\  is invoked from the command line, as follows, to edit an existing
data base file:

\begin{verbatim}

EditLibr -editfile <filename>
 
\end{verbatim}
or like this to create a new data base file:
\begin{verbatim}

EditLibr -editfile <filename> -minpages <pages>

\end{verbatim}
where \verb+<filename>+ is the name of the file to be edited or created
and \verb+<pages>+\index{card catalog db@{\bf card catalog db}!index pages in}
is the number of index pages to pre-allocate when
creating a new file.  Each index page stores upto 21 index keys. 
Remember, there are four indexes.  If while editing your data base, you
run out of pre-allocated index pages, more will be allocated.  The
difference will be that new index pages are allocated from the end of
the file on an as needed basis.  If pages get allocated this way
the index table will be fragmented.  Pre-allocating the
pages puts them all new at the beginning of the file, for faster
access\footnote{These pages are cached using a simple ``virtual memory''
scheme, so disk access is minimized.}. 

\section{Using \EditLibr.}

\subsection{The Main Command Menu.}

When \EditLibr\  starts up, it displays its main menu, as shown in
Figure~\ref{fig:edmainmenu}.

\begin{figure}
\caption{Main command menu of \EditLibr.}
\label{fig:edmainmenu}
\index{gui@{{\bf GUI} (Graphical User Interface)}!editor main menu}

\begin{picture}(330,290)
\put(0,0){
\fbox{
\begin{picture}(320,280)

\put(100,256){\tt Main Command Menu}

\put(0,232){\tt Quit}
\put(0,220){\tt Edit a Card}
\put(0,208){\tt Delete a Card}
\put(0,196){\tt Delete by Author}
\put(0,184){\tt Delete by Title}
\put(0,172){\tt Delete by Subject}
\put(0,160){\tt List Cards}
\put(0,148){\tt List Titles}
\put(0,136){\tt List Authors}
\put(0,124){\tt List Subjects}
\put(0,112){\tt Spawn Shell}

\end{picture}
}}
\end{picture}

\end{figure}

\subsubsection{The {\tt Quit} Menu Item.}

The {\tt Quit} menu item causes \EditLibr\ to close the data base file
and exit.

\subsubsection{The {\tt Edit a Card} Menu Item.}

The {\tt Edit a Card} menu item is used to edit a specific card in the
data base.  You are prompted for a card id, and the card editor is
invoked. The card editor is described in Section~\ref{sec:editcard}.

\subsubsection{The {\tt Delete a Card} Menu Item.}\

The {\tt Delete a Card} menu item is used to delete a selected card by
its id.  You are prompted for the id of the card to delete.

\subsubsection{The {\tt Delete by Author} Menu Item.}

The {\tt Delete by Author} menu item is used to delete some or all
cards for items written by a selected author.  You are prompted for an
author and then the card ids for that author are listed one by one and
you are asked if you want to delete each card.

\subsubsection{The {\tt Delete by Title} Menu Item.}

The {\tt Delete by Title} menu item is used to delete some or all
cards for items with a selected title.  You are prompted for an
title and then the card ids for that title are listed one by one and
you are asked if you want to delete each card.

\subsubsection{The {\tt Delete by Subject} Menu Item.}

The {\tt Delete by Subject} menu item is used to delete some or all
cards for items with a selected subject.  You are prompted for an
subject and then the card ids for that subject are listed one by one and
you are asked if you want to delete each card.

\subsubsection{The {\tt List Cards} Menu Item.}

The {\tt List Cards} menu item lists cards with their titles which have
a common selected prefix for their id strings.  You are prompted for a
search prefix and those cards with a matching prefix string in their id
string are listed.  You have the option of editing a selected
card.

\subsubsection{The {\tt List Titles} Menu Item.}

The {\tt List Titles} menu item lists titles with a common selected
prefix string.  You are prompted for a search prefix and those titles
with a matching prefix string are listed.  You have the option of
selecting one of the listed titles\footnote{If only one title matches,
it is automatically selected}, in which case the ids for the selected
title are listed (much as in the {\tt List Cards} menu item)\footnote{If
the title only refers to a single card, that card is placed in the card
editor directly}.

\subsubsection{The {\tt List Authors} Menu Item.}

The {\tt List Authors} menu item lists authors with a common selected
prefix string.  You are prompted for a search prefix and those authors
with a matching prefix string are listed.  You have the option of
selecting one of the listed authors\footnote{If only one author matches,
it is automatically selected}, in which case the ids for the selected
author are listed (much as in the {\tt List Cards} menu item)\footnote{If
the author only refers to a single card, that card is placed in the card
editor directly}.

\subsubsection{The {\tt List Subjects} Menu Item.}

The {\tt List Subjects} menu item lists subjects with a common selected
prefix string.  You are prompted for a search prefix and those subjects
with a matching prefix string are listed.  You have the option of
selecting one of the listed subjects\footnote{If only one subject matches,
it is automatically selected}, in which case the ids for the selected
subject are listed (much as in the {\tt List Cards} menu item)\footnote{If
the subject only refers to a single card, that card is placed in the card
editor directly}.

\subsubsection{The {\tt Spawn Shell} Menu Item.}

The {\tt Spawn Shell} menu item forks a sub-shell process.

\subsection{Card Editor.}\index{card@{\bf card}!editing}
\label{sec:editcard}

When the card editor is invoked, it checks to see if the card to be
edited exists in the data base or not. If the card does not exist, you
are asked if you want to create a new card.  The card editor then puts
up a screen as in Figure~\ref{fig:edcard}. 
\begin{figure}
\caption{Edit Card Screen of \EditLibr.} 
\label{fig:edcard}
\index{gui@{{\bf GUI} (Graphical User Interface)}!card editor screen}
\begin{picture}(330,290) 
\put(0,0){ \fbox{ 
\begin{picture}(320,280)
\put(100,256){\tt Editing a Card}

\put(0,232){\tt Id:}
\put(25,232){\tt \char'074 id\char'076}
\put(240,232){\tt Type:}
\put(275,232){\tt \char'074 type\char'076}

\put(0,220){\tt Title:}
\put(40,220){\tt \char'074 title\char'076}

\put(0,208){\tt Author:}
\put(45,208){\tt \char'074 author\char'076}

\put(0,196){\tt Publisher:}
\put(60,196){\tt \char'074 publisher\char'076}
\put(240,196){\tt Year:}
\put(275,196){\tt \char'074 year\char'076}

\put(0,184){\tt City:}
\put(35,184){\tt \char'074 city\char'076}
\put(240,184){\tt Vol:}
\put(265,184){\tt \char'074 volume\char'076}

\put(0,172){\tt Description:}
\put(75,172){\tt \char'074 description\char'076}

\put(0,36){\tt Subjects:}
\put(60,36){\tt \char'074 subject list\char'076}

\end{picture}
}}
\end{picture}

\end{figure}
The card editor defines the key bindings shown in
Table~\ref{tab:edcardkey}
\index{gui@{{\bf GUI} (Graphical User Interface)}!card editor screen!key bindings in}
\edcardkey
The \verb+i+ (or \verb+I+) key is used to modify fields.  The {\tt id}
field cannot be modified.  When the displayed card is different from the
stored card, an asterisk (\verb+*+) is displayed in the uppper left
corner of the screen.  Most of the fields are updated by simply typing
the \verb+i+ (or \verb+I+) key and then re-typing the field and pressing
the \verb+Return+ or \verb+Enter+ key.  Two fields are different.  The
{\tt description} and {\tt subject} fields are modified using an
external text editor\footnote{Defined by the {\tt EDITOR} environment
variable or {\tt umacs} by default under OSK and {\tt ???} by default
under MS-DOS.}.  Entering the \verb+i+ (or \verb+I+) key spawns the
external editor with a temp file containing the field to be modified.
